1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module sourceview.GutterLines;
26 
27 private import glib.MemorySlice;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.TextBuffer;
31 private import gtk.TextIter;
32 private import gtk.TextView;
33 private import sourceview.c.functions;
34 public  import sourceview.c.types;
35 
36 
37 /**
38  * Collected information about visible lines.
39  * 
40  * The `GtkSourceGutterLines` object is used to collect information about
41  * visible lines.
42  * 
43  * Use this from your [signal@GutterRenderer::query-data] to collect the
44  * necessary information on visible lines. Doing so reduces the number of
45  * passes through the text btree allowing GtkSourceView to reach more
46  * frames-per-second while performing kinetic scrolling.
47  */
48 public class GutterLines : ObjectG
49 {
50 	/** the main Gtk struct */
51 	protected GtkSourceGutterLines* gtkSourceGutterLines;
52 
53 	/** Get the main Gtk struct */
54 	public GtkSourceGutterLines* getGutterLinesStruct(bool transferOwnership = false)
55 	{
56 		if (transferOwnership)
57 			ownedRef = false;
58 		return gtkSourceGutterLines;
59 	}
60 
61 	/** the main Gtk struct as a void* */
62 	protected override void* getStruct()
63 	{
64 		return cast(void*)gtkSourceGutterLines;
65 	}
66 
67 	/**
68 	 * Sets our main struct and passes it to the parent class.
69 	 */
70 	public this (GtkSourceGutterLines* gtkSourceGutterLines, bool ownedRef = false)
71 	{
72 		this.gtkSourceGutterLines = gtkSourceGutterLines;
73 		super(cast(GObject*)gtkSourceGutterLines, ownedRef);
74 	}
75 
76 
77 	/** */
78 	public static GType getType()
79 	{
80 		return gtk_source_gutter_lines_get_type();
81 	}
82 
83 	/**
84 	 * Adds the class @name to @line.
85 	 *
86 	 * @name will be converted to a [alias@GLib.Quark] as part of this process. A
87 	 * faster version of this function is available via
88 	 * [method@GutterLines.add_qclass] for situations where the [alias@GLib.Quark] is
89 	 * known ahead of time.
90 	 *
91 	 * Params:
92 	 *     line = a line number starting from zero
93 	 *     name = a class name
94 	 */
95 	public void addClass(uint line, string name)
96 	{
97 		gtk_source_gutter_lines_add_class(gtkSourceGutterLines, line, Str.toStringz(name));
98 	}
99 
100 	/**
101 	 * Adds the class denoted by @qname to @line.
102 	 *
103 	 * You may check if a line has @qname by calling
104 	 * [method@GutterLines.has_qclass].
105 	 *
106 	 * You can remove @qname by calling
107 	 * [method@GutterLines.remove_qclass].
108 	 *
109 	 * Params:
110 	 *     line = a line number starting from zero
111 	 *     qname = a class name as a #GQuark
112 	 */
113 	public void addQclass(uint line, GQuark qname)
114 	{
115 		gtk_source_gutter_lines_add_qclass(gtkSourceGutterLines, line, qname);
116 	}
117 
118 	/**
119 	 * Gets the [class@Gtk.TextBuffer] that the `GtkSourceGutterLines` represents.
120 	 *
121 	 * Returns: a #GtkTextBuffer
122 	 */
123 	public TextBuffer getBuffer()
124 	{
125 		auto __p = gtk_source_gutter_lines_get_buffer(gtkSourceGutterLines);
126 
127 		if(__p is null)
128 		{
129 			return null;
130 		}
131 
132 		return ObjectG.getDObject!(TextBuffer)(cast(GtkTextBuffer*) __p);
133 	}
134 
135 	/**
136 	 * Gets the line number (starting from 0) for the first line that is
137 	 * user visible.
138 	 *
139 	 * Returns: a line number starting from 0
140 	 */
141 	public uint getFirst()
142 	{
143 		return gtk_source_gutter_lines_get_first(gtkSourceGutterLines);
144 	}
145 
146 	/**
147 	 * Gets a #GtkTextIter for the current buffer at @line
148 	 *
149 	 * Params:
150 	 *     iter = a location for a #GtkTextIter
151 	 *     line = the line number
152 	 */
153 	public void getIterAtLine(out TextIter iter, uint line)
154 	{
155 		GtkTextIter* outiter = sliceNew!GtkTextIter();
156 
157 		gtk_source_gutter_lines_get_iter_at_line(gtkSourceGutterLines, outiter, line);
158 
159 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
160 	}
161 
162 	/**
163 	 * Gets the line number (starting from 0) for the last line that is
164 	 * user visible.
165 	 *
166 	 * Returns: a line number starting from 0
167 	 */
168 	public uint getLast()
169 	{
170 		return gtk_source_gutter_lines_get_last(gtkSourceGutterLines);
171 	}
172 
173 	/**
174 	 * Gets the Y range for a line based on @mode.
175 	 *
176 	 * The value for @y is relative to the renderers widget coordinates.
177 	 *
178 	 * Params:
179 	 *     line = a line number starting from zero
180 	 *     mode = a #GtkSourceGutterRendererAlignmentMode
181 	 *     y = a location for the Y position in widget coordinates
182 	 *     height = the line height based on @mode
183 	 */
184 	public void getLineYrange(uint line, GtkSourceGutterRendererAlignmentMode mode, out int y, out int height)
185 	{
186 		gtk_source_gutter_lines_get_line_yrange(gtkSourceGutterLines, line, mode, &y, &height);
187 	}
188 
189 	/**
190 	 * Gets the [class@Gtk.TextView] that the `GtkSourceGutterLines` represents.
191 	 *
192 	 * Returns: a #GtkTextView
193 	 */
194 	public TextView getView()
195 	{
196 		auto __p = gtk_source_gutter_lines_get_view(gtkSourceGutterLines);
197 
198 		if(__p is null)
199 		{
200 			return null;
201 		}
202 
203 		return ObjectG.getDObject!(TextView)(cast(GtkTextView*) __p);
204 	}
205 
206 	/**
207 	 * Checks to see if [method@GutterLines.add_class] was called with
208 	 * the @name for @line.
209 	 *
210 	 * A faster version of this function is provided via
211 	 * [method@GutterLines.has_qclass] for situations where the quark
212 	 * is known ahead of time.
213 	 *
214 	 * Params:
215 	 *     line = a line number starting from zero
216 	 *     name = a class name that may be converted, to a #GQuark
217 	 *
218 	 * Returns: %TRUE if @line contains @name
219 	 */
220 	public bool hasClass(uint line, string name)
221 	{
222 		return gtk_source_gutter_lines_has_class(gtkSourceGutterLines, line, Str.toStringz(name)) != 0;
223 	}
224 
225 	/**
226 	 * Checks to see if [method@GutterLines.add_qclass] was called with
227 	 * the quark denoted by @qname for @line.
228 	 *
229 	 * Params:
230 	 *     line = a line number starting from zero
231 	 *     qname = a #GQuark containing the class name
232 	 *
233 	 * Returns: %TRUE if @line contains @qname
234 	 */
235 	public bool hasQclass(uint line, GQuark qname)
236 	{
237 		return gtk_source_gutter_lines_has_qclass(gtkSourceGutterLines, line, qname) != 0;
238 	}
239 
240 	/**
241 	 * Checks to see if @line contains the insertion cursor.
242 	 *
243 	 * Params:
244 	 *     line = a line number starting from zero
245 	 *
246 	 * Returns: %TRUE if the insertion cursor is on @line
247 	 */
248 	public bool isCursor(uint line)
249 	{
250 		return gtk_source_gutter_lines_is_cursor(gtkSourceGutterLines, line) != 0;
251 	}
252 
253 	/**
254 	 * Checks to see if @line is marked as prelit. Generally, this means
255 	 * the mouse pointer is over the line within the gutter.
256 	 *
257 	 * Params:
258 	 *     line = a line number starting from zero
259 	 *
260 	 * Returns: %TRUE if the line is prelit
261 	 */
262 	public bool isPrelit(uint line)
263 	{
264 		return gtk_source_gutter_lines_is_prelit(gtkSourceGutterLines, line) != 0;
265 	}
266 
267 	/**
268 	 * Checks to see if the view had a selection and if that selection overlaps
269 	 * @line in some way.
270 	 *
271 	 * Params:
272 	 *     line = a line number starting from zero
273 	 *
274 	 * Returns: %TRUE if the line contains a selection
275 	 */
276 	public bool isSelected(uint line)
277 	{
278 		return gtk_source_gutter_lines_is_selected(gtkSourceGutterLines, line) != 0;
279 	}
280 
281 	/**
282 	 * Removes the class matching @name from @line.
283 	 *
284 	 * A faster version of this function is available via
285 	 * [method@GutterLines.remove_qclass] for situations where the
286 	 * #GQuark is known ahead of time.
287 	 *
288 	 * Params:
289 	 *     line = a line number starting from zero
290 	 *     name = a class name
291 	 */
292 	public void removeClass(uint line, string name)
293 	{
294 		gtk_source_gutter_lines_remove_class(gtkSourceGutterLines, line, Str.toStringz(name));
295 	}
296 
297 	/**
298 	 * Reverses a call to [method@GutterLines.add_qclass] by removing
299 	 * the [alias@GLib.Quark] matching @qname.
300 	 *
301 	 * Params:
302 	 *     line = a line number starting from zero
303 	 *     qname = a #GQuark to remove from @line
304 	 */
305 	public void removeQclass(uint line, GQuark qname)
306 	{
307 		gtk_source_gutter_lines_remove_qclass(gtkSourceGutterLines, line, qname);
308 	}
309 }